package com.pi.controller;

import com.pi.dao.ReceiveDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.Enumeration;

public class ReceiveDataController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        req.setCharacterEncoding("utf-8");
        System.out.println(req.getParameterMap().get("user_id")[0]);
        try {
            if(new ReceiveDao().insertReportData(req.getParameterMap())){
                PrintWriter writer=resp.getWriter();

                writer.println("<h1>提交成功</h1>");
                writer.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
